package com.zhibang.bbgl.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.ObjectMapper;

import com.zhibang.bbgl.service.BbglService;
import com.zhibang.bbgl.service.lmp.BbglServiceImp;
import com.zhibang.comnom.domain.*;
import com.zhibang.comnom.re.Result;
import com.zhibang.comnom.re.ResultCode;
import com.zhibang.comnom.vo.JcVo;
import com.zhibang.comnom.vo.JcjlVo;
import com.zhibang.comnom.vo.SccPatientVo;

import com.zhibang.comnom.vo.Sccyd;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
@CrossOrigin
@RestController
@Api(tags = "报表管理接口")
@RequestMapping("/bbgl")
public class BbglController {
    @Resource
    private BbglService BbglServiceImp;


    @RequestMapping(value = "Iffind",method = RequestMethod.GET)
    @ApiOperation(value = "根据条件查询用户与药店关系")
    public Result iffind(String searchParams)throws Exception{
        ObjectMapper objectMapper = new ObjectMapper();

      SccPatientVo sccPatientVo = null;
        if (searchParams!=null){
            sccPatientVo=objectMapper.readValue(searchParams, SccPatientVo.class);
            System.out.println(sccPatientVo);
        }
         List<Sccyd>find =BbglServiceImp.tjcx(sccPatientVo);
        System.out.println(find);
        return Result.ok(ResultCode.SUCCESS,find);
    }

    @RequestMapping(value = "xztp",method = RequestMethod.GET)
    @ApiOperation(value = "根据条件查询消费者图谱")
    public Result xztp(String searchParams)throws Exception{
        ObjectMapper objectMapper = new ObjectMapper();

        JcVo jcVo = null;
        if (searchParams!=null){
            jcVo=objectMapper.readValue(searchParams,JcVo.class);
            System.out.println(jcVo);
        }
        List<Xfzsjtp> xfzsjtps = BbglServiceImp.xztp(jcVo);
        System.out.println(xfzsjtps);
        return Result.ok(ResultCode.SUCCESS,xfzsjtps);
    }

    @RequestMapping(value = "xftp",method = RequestMethod.GET)
    @ApiOperation(value = "查询每个月的检测次数总和至图表")
    public Result xftp()throws Exception{
        List<Xftb> xftbs= BbglServiceImp.xftb();
        System.out.println(xftbs);
        return Result.ok(ResultCode.SUCCESS,xftbs);
    }
    @RequestMapping(value = "zbyc",method = RequestMethod.POST)
    @ApiOperation(value = "查看指标异常的男女数")
    public Result zbyc(String searchParams)throws Exception{
        ObjectMapper objectMapper = new ObjectMapper();
       ZbycVo zbycVo = null;

        if (searchParams!=null){
            zbycVo=objectMapper.readValue(searchParams,ZbycVo.class);
            System.out.println(zbycVo);
        }
        List<Zbyc> zbycs = BbglServiceImp.zbyc(zbycVo);
        return Result.ok(ResultCode.SUCCESS,zbycs);

    }
    @RequestMapping(value = "zbycVO",method = RequestMethod.POST)
    @ApiOperation(value = "据条件查看指标异常的男女数")
    public Result zbycVo(String searchParams)throws Exception{
        ObjectMapper objectMapper = new ObjectMapper();
        ZbycVo zbycVo = null;

        if (searchParams!=null){
            zbycVo=objectMapper.readValue(searchParams,ZbycVo.class);
            System.out.println(zbycVo);
        }
        List<Zbyc> zbycs = BbglServiceImp.zbyc(zbycVo);
        return Result.ok(ResultCode.SUCCESS,zbycs);

    }
    @RequestMapping(value = "jcjl",method = RequestMethod.GET)
    @ApiOperation(value = "查询报表模块的检测记录")
    public Result jcjl(String searchParams)throws Exception{
             ObjectMapper objectMapper = new ObjectMapper();
        JcjlVo jcjlVo = null;
        if (searchParams!=null){
              jcjlVo =objectMapper.readValue(searchParams,JcjlVo.class);
        }
        List<Jcjl>jcjls = BbglServiceImp.jcjl(jcjlVo);
        return Result.ok(ResultCode.SUCCESS,jcjls);
    }
}
